package net.cloudcodex.client.storyboard.player.view;

import net.cloudcodex.client.storyboard.command.view.CommandView;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.LayoutPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.inject.Inject;

/**
 * 
 * 
 * @author ADaroussin
 */
public class PlayerBoardViewImpl extends DockLayoutPanel implements PlayerBoardView {
	private final FlowPanel sceneContainer = new FlowPanel();
	private final LayoutPanel commandPanel = new LayoutPanel();
	private final Button newSceneButton = new Button("New Scene");
	private final Button talkButton = new Button("Talk");
	private final Button offButton = new Button("OFF");
	private final Button rollButton = new Button("Roll Dice");
	private final Button deleteButton = new Button("Delete message");
	private final Button reindexButton = new Button("Reindex message");

	@Inject
	public PlayerBoardViewImpl(Message message) {
		super(Unit.PX);
		// FIXME: Why style "position: relative" hide child elements?
		this.getElement().addClassName("cc-ForceStatic");

		this.addSouth(commandPanel,150);

		final DockLayoutPanel buttonBar = new DockLayoutPanel(Unit.PX);
		buttonBar.addWest(newSceneButton, 100);
		buttonBar.addWest(talkButton, 100);
		buttonBar.addWest(offButton, 100);
		buttonBar.addWest(rollButton, 100);
		buttonBar.addWest(deleteButton, 100);
		buttonBar.addWest(reindexButton, 100);
		this.addSouth(buttonBar, 30);

		final ScrollPanel scrollPanel = new ScrollPanel(sceneContainer);
		this.add(scrollPanel);
	}

	@Override
	public void addScene(SceneView scene) {
		sceneContainer.add(scene);
	}

	@Override
	public HasClickHandlers getNewSceneButton() {
		return this.newSceneButton;
	}

	@Override
	public HasClickHandlers getTalkButton() {
		return this.talkButton;
	}

	@Override
	public HasClickHandlers getOffButton() {
		return this.offButton;
	}

	@Override
	public Button getRollButton() {
		return rollButton;
	}

	@Override
	public HasClickHandlers getDeleteButton() {
		return this.deleteButton;
	}

	@Override
	public Button getReindexButton() {
		return reindexButton;
	}

	@Override
	public void setCommand(CommandView command) {
		this.commandPanel.add(command);
	}
}
